package com.lovo.controller;


import com.lovo.bean.Address;
import com.lovo.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * ?û????ջ???ַ? 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-09-17
 */
@RestController
@RequestMapping("qd/address")
public class AddressController {

    @Autowired
    IAddressService addressService;

    @GetMapping("findAddressById/{userId}")
    public List<Address> findAddressById(@PathVariable("userId") Integer userId) {
        return addressService.findAddressById(userId);
    }

    @GetMapping("addAddress")
    public String addAddress(Address address) {
        addressService.addAddress(address);
        return "ok";
    }

    @DeleteMapping("delAddress/{addressId}")
    public String delAddress(@PathVariable("addressId") Integer addressId) {
        addressService.delAddress(addressId);
        return "ok";
    }

}
